1312B - Bogosort - CodeForces Solution


constructive algorithms sortings *1000

Please click on ads to support us..

Python Code:

for _ in range(int(input())):
    n=int(input())
    print(*sorted(list(map(int,input().split())))[::-1])

C++ Code:

#include <bits/stdc++.h>
#define ll long long 
using namespace std;
int main ()
{
    ll T;
    cin >> T;
 
    while (T --){
        ll n;
        cin >> n;
 
        ll arr[n];
        for (ll i = 0; i < n; i ++){
            cin >> arr[i];
        }
 
        sort (arr , arr + n);
 
        for (ll i = n - 1; i >= 0; i --){
            cout << arr[i] << " ";
        }
 
        cout << endl;
    }
 
    return 0;
}


Comments

Submit
0 Comments
More Questions

84. Largest Rectangle in Histogram
60. Permutation Sequence
42. Trapping Rain Water
32. Longest Valid Parentheses
Cutting a material
Bubble Sort
Number of triangles
AND path in a binary tree
Factorial equations
Removal of vertices
Happy segments
Cyclic shifts
Zoos
Build a graph
Almost correct bracket sequence
Count of integers
Differences of the permutations
Doctor's Secret
Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship